﻿@using Janus.BaseEntitys;
@using System.Text.RegularExpressions;
@model IEnumerable<ModuleDTO>
@{
    var currentButtons = new List<ModuleDTO>();
    if (Model == null || Model.Count() == 0)
    {
        currentButtons = ViewData["CurrentPageButtons"] as List<ModuleDTO>;
    }
    else
    {
        currentButtons = new List<ModuleDTO>(Model);
    }
    currentButtons = currentButtons ?? new List<ModuleDTO>();
}
@if (currentButtons.Count > 0)
{
    <div class="panelBar">
        <ul class="toolBar">
            @foreach (var item in currentButtons)
            {
                string currentUrl = item.Url == "#" ? "javascript:" : Html.FormateUrl(item.Url, item.ID, item.ParmFormat);
                string width = string.Format(" width={0}", item.Width == 0 ? 850 : item.Width);
                string height = string.Format(" height={0}", item.Height == 0 ? 400 : item.Height);
                <li>
                    @if (item.IsDisable.HasValue && item.IsDisable.Value)
                    {
                        <a class="disabled"><span><span class="@(item.CssClass ?? "add")"></span>@item.ModuleName</span></a>

                    }
                    else
                    {
                        <a id="@item.ID" @width @height href='@currentUrl' class="@(item.CssClass)" max="@(item.Max?"true":"false")" target="@(item.Target ?? "navTab")" title="@item.Title" @(!string.IsNullOrEmpty(item.Warn) ? "Warn=" + item.Warn : string.Empty) rel="@item.ID" onclick="return @item.OnCilck" ref="@currentUrl" callback="@item.CallBack">
                            <span><span class="@(item.CssClass ?? "add")"></span>@item.ModuleName</span>
                        </a>
                    }
                </li>
            }
        </ul>
    </div>
}
